from build_in import datetime, date, decimal, uuid
from flask import Flask, Blueprint, request
from flask.json import JSONEncoder as _JSONEncoder
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_script import Manager


class JSONEncoder(_JSONEncoder):
    def default(self, o):
        if isinstance(o, datetime):
            return o.strftime('%Y-%m-%d %H:%M:%S')
        elif isinstance(o, date):
            return o.strftime('%Y-%m-%d')
        elif isinstance(o, decimal.Decimal):
            return str(o)
        elif isinstance(o, uuid.UUID):
            return str(o)
        elif isinstance(o, bytes):
            return o.decode('utf-8')
        else:
            _JSONEncoder.default(self, o)


